<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Start datafeeds API | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'ml-start-datafeed.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/ml-start-datafeed.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/ml-start-datafeed.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/ml-start-datafeed.html" rel="nofollow" target="_blank">../en/ml-start-datafeed.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="rest-apis.html">REST APIs</a></span>
»
<span class="breadcrumb-link"><a href="ml-apis.html">Machine learning anomaly detection APIs</a></span>
»
<span class="breadcrumb-node">Start datafeeds API</span>
</div>
<div class="navheader">
<span class="prev">
<a href="ml-set-upgrade-mode.html">« Set upgrade mode API</a>
</span>
<span class="next">
<a href="ml-stop-datafeed.html">Stop datafeeds API »</a>
</span>
</div>
<div class="section xpack">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="ml-start-datafeed"></a>Start datafeeds API<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/start-datafeed.asciidoc">edit</a><a class="xpack_tag" href="https://www.elastic.co/subscriptions"></a>
</h2>
</div></div></div>

<p>Starts one or more datafeeds.</p>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-start-datafeed-request"></a>Request<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/start-datafeed.asciidoc">edit</a>
</h3>
</div></div></div>
<p><code class="literal">POST _ml/datafeeds/&lt;feed_id&gt;/_start</code></p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-start-datafeed-prereqs"></a>Prerequisites<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/start-datafeed.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
Before you can start a datafeed, the anomaly detection job must be open. Otherwise, an
error occurs.
</li>
<li class="listitem">
If Elasticsearch security features are enabled, you must have <code class="literal">manage_ml</code> or <code class="literal">manage</code>
cluster privileges to use this API. See
<a class="xref" href="security-privileges.html" title="Security privileges">Security privileges</a>.
</li>
</ul>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-start-datafeed-desc"></a>Description<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/start-datafeed.asciidoc">edit</a>
</h3>
</div></div></div>
<p>A datafeed must be started in order to retrieve data from Elasticsearch.
A datafeed can be started and stopped multiple times throughout its lifecycle.</p>
<p>When you start a datafeed, you can specify a start time.  This enables you to
include a training period, providing you have this data available in Elasticsearch.
If you want to analyze from the beginning of a dataset, you can specify any date
earlier than that beginning date.</p>
<p>If you do not specify a start time and the datafeed is associated with a new
anomaly detection job, the analysis starts from the earliest time for which data is
available.</p>
<p>When you start a datafeed, you can also specify an end time. If you do so, the
job analyzes data from the start time until the end time, at which point the
analysis stops.  This scenario is useful for a one-off batch analysis.  If you
do not specify an end time, the datafeed runs continuously.</p>
<p>The <code class="literal">start</code> and <code class="literal">end</code> times can be specified by using one of the
following formats:<br></p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
ISO 8601 format with milliseconds, for example <code class="literal">2017-01-22T06:00:00.000Z</code>
</li>
<li class="listitem">
ISO 8601 format without milliseconds, for example <code class="literal">2017-01-22T06:00:00+00:00</code>
</li>
<li class="listitem">
Milliseconds since the epoch, for example <code class="literal">1485061200000</code>
</li>
</ul>
</div>
<p>Date-time arguments using either of the ISO 8601 formats must have a time zone
designator, where Z is accepted as an abbreviation for UTC time.</p>
<div class="note admon">
<div class="icon"></div>
<div class="admon_content">
<p>When a URL is expected (for example, in browsers), the <code class="literal">+</code> used in time
zone designators must be encoded as <code class="literal">%2B</code>.</p>
</div>
</div>
<p>If the system restarts, any jobs that had datafeeds running are also restarted.</p>
<p>When a stopped datafeed is restarted, it continues processing input data from
the next millisecond after it was stopped. If new data was indexed for that
exact millisecond between stopping and starting, it will be ignored.
If you specify a <code class="literal">start</code> value that is earlier than the timestamp of the latest
processed record, the datafeed continues from 1 millisecond after the timestamp
of the latest processed record.</p>
<div class="important admon">
<div class="icon"></div>
<div class="admon_content">
<p>When Elasticsearch security features are enabled, your datafeed remembers
which roles the last user to create or update it had at the time of
creation/update and runs the query using those same roles.</p>
</div>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-start-datafeed-path-parms"></a>Path parameters<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/start-datafeed.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">&lt;feed_id&gt;</code>
</span>
</dt>
<dd>
(Required, string)
A numerical character string that uniquely identifies the
datafeed. This identifier can contain lowercase alphanumeric characters (a-z
and 0-9), hyphens, and underscores. It must start and end with alphanumeric
characters.
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-start-datafeed-request-body"></a>Request body<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/start-datafeed.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">end</code>
</span>
</dt>
<dd>
(Optional, string) The time that the datafeed should end. This value is
exclusive. The default value is an empty string.
</dd>
<dt>
<span class="term">
<code class="literal">start</code>
</span>
</dt>
<dd>
(Optional, string) The time that the datafeed should begin. This value is
inclusive. The default value is an empty string.
</dd>
<dt>
<span class="term">
<code class="literal">timeout</code>
</span>
</dt>
<dd>
(Optional, time) Controls the amount of time to wait until a datafeed starts.
The default value is 20 seconds.
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-start-datafeed-example"></a>Examples<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/start-datafeed.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">POST _ml/datafeeds/datafeed-total-requests/_start
{
  "start": "2017-04-07T18:22:16Z"
}</pre>
</div>
<div class="console_widget" data-snippet="snippets/1838.console"></div>
<p>When the datafeed starts, you receive the following results:</p>
<div class="pre_wrapper lang-console-result">
<pre class="programlisting prettyprint lang-console-result">{
  "started": true
}</pre>
</div>
</div>

</div>
<div class="navfooter">
<span class="prev">
<a href="ml-set-upgrade-mode.html">« Set upgrade mode API</a>
</span>
<span class="next">
<a href="ml-stop-datafeed.html">Stop datafeeds API »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>